package com.lindroy.androidplayer.ui.adapter

import androidx.lifecycle.LifecycleOwner
import com.lindroy.androidplayer.base.adapter.BaseListAdapter
import com.lindroy.androidplayer.databinding.KnowledgeSystemIndexItemBinding
import com.lindroy.androidplayer.databinding.KnowledgeSystemItemBinding
import com.lindroy.androidplayer.viewmodels.KnowledgeItemViewModel

/**
 * @author Lin
 * @date 2022/1/24
 * @function
 */
class KnowledgeIndexAdapter(owner: LifecycleOwner) :
    BaseListAdapter<KnowledgeItemViewModel, KnowledgeSystemIndexItemBinding>(owner) {

    override fun KnowledgeSystemIndexItemBinding.onBindViewHolder(
        item: KnowledgeItemViewModel,
        position: Int
    ) {
        vm = item
    }

    override fun artItemsTheSame(
        oldItem: KnowledgeItemViewModel,
        newItem: KnowledgeItemViewModel
    ) = oldItem.id == newItem.id

    override fun areContentsTheSame(
        oldItem: KnowledgeItemViewModel,
        newItem: KnowledgeItemViewModel
    ) = oldItem == newItem
}